//
//  MyFormViewController.m
//  HTP
//
//  Created by 王鑫 on 15/11/1.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "MyFormViewController.h"
#import "PayOffViewController.h"
#import "PaidViewController.h"

@interface MyFormViewController () <UITabBarControllerDelegate>

@property (nonatomic, retain) UITabBarController *myFormTabBarController;

@end

@implementation MyFormViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initTabBar];
    [self addBackBtn:@""];
    [self.view addSubview:self.myFormTabBarController.view];
    // Do any additional setup after loading the view.
}

- (void)initTabBar {
    
    _myFormTabBarController = [[UITabBarController alloc] init];
    [_myFormTabBarController.tabBar setFrame:CGRectMake(0, 54, ScreenWidth, 45)];
    _myFormTabBarController.view.backgroundColor = [UIColor whiteColor];
//    _myFormTabBarController.tabBar.itemPositioning = UITabBarItemPositioningCentered;
    _myFormTabBarController.tabBar.backgroundColor = [UIColor whiteColor];
    [_myFormTabBarController.tabBar setAlpha:1];
    _myFormTabBarController.tabBar.tintColor = [UIColor orangeColor];
    _myFormTabBarController.delegate = self;
    
    UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenWidth / 2.0, 2, 1, 45)];
    line.image = [UIImage imageNamed:@"竖线"];
    [_myFormTabBarController.tabBar addSubview:line];
    
    UITabBarItem *paidTabBarItem = [[UITabBarItem alloc] init];
    [paidTabBarItem setTitle:@"已支付"];
    [paidTabBarItem setTag:1];
    
    UITabBarItem *payOffTabBarItem = [[UITabBarItem alloc] init];
    [payOffTabBarItem setTitle:@"未支付"];
    [payOffTabBarItem setTag:0];
    
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor],NSFontAttributeName:[UIFont systemFontOfSize:20.0f]} forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, -9)];
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor orangeColor],NSFontAttributeName:[UIFont systemFontOfSize:20.0f]} forState:UIControlStateSelected];
    
    PaidViewController *paidView = [[PaidViewController alloc] init];
    paidView.tabBarItem = paidTabBarItem;
    
    PayOffViewController *payOffView = [[PayOffViewController alloc] init];
    payOffView.tabBarItem = payOffTabBarItem;
    
    [_myFormTabBarController setViewControllers:[NSArray arrayWithObjects:paidView,payOffView,nil]];
    _myFormTabBarController.selectedIndex = 0;
    
    
}

/**
 *  上面的tabBar点击事件
 *
 *  @param tabBarController
 *  @param viewController
 **/

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    
    switch (tabBarController.selectedIndex) {
        case 0:
            break;
            
        case 1:
            break;
        default:
            break;
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
